package inteface.utils;
import java.io.File;
import javax.swing.filechooser.FileFilter;

/**
*  TERFileFilter.
* 
*  @author Vincent GUIJARRO
*  @version 0.2, 24/03/06
*/
/* ImageFilter.java is a 1.4 example used by FileChooserDemo2.java. */
public class TERFileFilter extends FileFilter {
	private String description;
	private String extensionAcceptee[];
	
	public TERFileFilter(String s, String[] ext) {
		description = s;
		extensionAcceptee = ext;
	}
	
	public TERFileFilter(String s, String ext) {
		description = s;
		extensionAcceptee = new String[1];
		extensionAcceptee[0] = ext;
	}
	
    //Accept all directories and all gif, jpg, tiff, or png files.
    public boolean accept(File f) {
        if (f.isDirectory()) {
            return true;
        }

        String extension = Utils.getExtension(f);
        if (extension != null) {
        	for (int i = 0; i < extensionAcceptee.length; i++)
        		if (extension.equals(extensionAcceptee[i]))
        			return true;
            return false;
        }

        return false;
    }

    //The description of this filter
    public String getDescription() {
        return description;
    }
}
